package eln.zaislu.muziejus;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;

public class Actor {
	 
	    private static final String TAG = Actor.class.getSimpleName();
	 
	    protected Bitmap bitmap;      // the animation sequence
	    protected int x;              // the X coordinate of the object (top left of the image)
	    protected int y;              // the Y coordinate of the object (top left of the image)
	    protected boolean touched; // if droid is touched/picked up
	    protected boolean animated;
	    protected boolean animationLooped;
	    protected int objid;
	    protected int soundID;
	    protected int frameWidth;
	    protected int frameHeight;
	    protected int animationOrientation;
	    
	    public Actor(Bitmap bitmap, int x, int y,boolean animated,boolean animationLooped,int objid,int soundid,int frameWidth,int frameHeight,int animationOrientation) {
	    	            this.animationOrientation=animationOrientation;
	    	            this.bitmap = bitmap;
	    	            this.y = y;
	    	            switch (animationOrientation){
	    	            case 0:this.x = x;break;
	    	            case 1:this.x = x+200;this.y = y-20;break;
	    	            case 2:this.x = x-150;this.y = y-20;break;
	    	            case 3:this.x = x-150;this.y = y-20;break;
	    	            case 4:this.x = x-100;this.y = y-30;break;
	    	            case 5:this.x = x-40;this.y = y-20;break;
	    	            } 
	    		        
	    		        this.animated=animated;
	    		        this.animationLooped=animationLooped;
	    		        this.objid=objid;
	    		        this.soundID=soundid;
	    		        this.frameWidth=frameWidth;
	    		        this.frameHeight=frameHeight;	        
	    		    }
	    
	 
	    public Bitmap getBitmap() {
			return bitmap;
		}
	    
	    public int getId() {
			return objid;
		}
		public void setBitmap(Bitmap bitmap) {
			this.bitmap = bitmap;
		}
	
		public int getX() {
			return x;
		}
		public void setX(int x) {
			this.x = x;
		}
		public int getY() {
			return y;
		}
		public void setY(int y) {
			this.y = y;
		}
		
		public int getBitmapWidth() {
			return bitmap.getWidth();
		}
		
		public int getBitmapHeight() {
			return bitmap.getHeight();
		}
		
		public int getFrameWidth() {
			return this.frameWidth;
		}
		
		public int getFrameHeight() {
			return this.frameHeight;
		}
		
		 public boolean isTouched() {
			  return touched;
			 }
		 
		 public boolean isAnimationLooped() {
			  return animationLooped;
			 }
		 
		 public void setAnimationLooped(boolean animationLooped) {
				this.animationLooped = animationLooped;
			}
		 
		 public boolean isAnimated() {
			  return animated;
			 }
			 
		 public void setTouched(boolean touched) {
			  this.touched = touched;
			 }
		
		 public void handleActionDown(int eventX, int eventY) {
			  if (eventX >= (x - bitmap.getWidth() / 2) && (eventX <= (x + bitmap.getWidth()/2))) {
			   if (eventY >= (y - bitmap.getHeight() / 2) && (y <= (y + bitmap.getHeight() / 2))) {
			    // droid touched
				   //int color = bitmap.getPixel(x,y); // x and y are the location of the touch event in Bitmap space
				   //int alpha = Color.alpha(color);
				   //boolean isTransparent = (alpha==0);
				   //if (!isTransparent){
				    // if (!animated){
			         setTouched(true);
				    // }else{
				    //	 if (eventX >= (x - frameWidth / 2) && (eventX <= (x + frameWidth/2))) 
					//		   if (eventY >= (y - frameHeight / 2) && (y <= (y + frameHeight / 2))) 
					 //              setTouched(true);
				     //}
			   } else {
			    setTouched(false);
			   }
			  } else {
			   setTouched(false);
			  }
			 
			 }
	}
